/**
 * Created by Administrator on 2018/1/22.
 */

var vm =  new Vue({
    el : "#app",
    data : {
        token:'',
        openId:'',
        reserveId:'',
        hotel:'',
        inTime:'',//入住时间
        outTime:'',//离店时间
        hotelName:'',//入住分店
        roomsNum:'',//房间数
        mobile:'',//手机号
        name:'',//入住人
        payPrice:'',//订单总额
        roomTypeName:'',//房型名
        roomTypeName:'',//房型名
        reserveNo:'',//订单号
        reserveStatus:'',//订单状态


    },
    created:function(){
        this.token = _lSGet('token');
        this.openId = _lSGet('openId');
        this.reserveId = _lSGet('reserveId');//获取订单号id
        this.hotel = _lSGet('hotelId');//酒店id或分店id//这里是上上上个页面传的非上个
        //载入时加载信息
        var that=this;
        var params = {};
        params.id = that.reserveId;//订单号id
        //params.hotelId = that.hotel;//酒店id
        params.token = that.token;
        sendRequest('/weChartOrder/get', params, function(res) {
            goLogin(res);
            //that.go_login_home(res)
            if(res.status==1){
                that.inTime= fmtDate(res.data.inTime);
                that.outTime= fmtDate(res.data.outTime);
                that.hotelName= res.data.hotelName;//入住分店
                that.roomsNum= res.data.roomCount;//房间数
                that.mobile= res.data.mobile;//手机号
                that.name= res.data.reserveName;//入住人
                that.reserveNo=res.data.reserveNo;
                that.roomTypeName= res.data.reserveModel.roomTypeName;//房间类型名
                that.payPrice= res.data.unpaidMoney;//订单总额
                that.reserveStatus= res.data.reserveStatus;//订单状态
                //that.time_end=res.data.leftTime;//结束时间
            }
        });

    },
    mounted:function(){


    },
    methods:{

        cancel:function(id){//取消订单
            var that=this;
            var params = {};
            params.id =that.reserveId;
            params.token = that.token;
            sendRequest('/weChartOrder/cancelReserve', params, function(res) {
                goLogin(res)
                //res = res.data;
                console.log('okla');
                console.log(res);
                // that.go_login_home(res);
                if(res.status == '1') {
                    tips(res.returnMsg);
                    //that.get_data();
                    window.location.reload();//重新加载页面
                    //that.hisOrder=res.rows;

                    //var array = [];
                }
            });
        },
        go_order:function(){//支付订单
            //alert(k)
            //alert(r)
            _lSSaveOrUpdate( 'reserveId', this.reserveId );//保存订单号 下个页面取出来使用
            // _lSSaveOrUpdate( 'hotelId', r );//保存酒店id 下个页面取出来使用
            window.location.href=indexUrl+'/app/payment.html?_t=' + Math.random();//点击支付跳到支付页面

        },



    },
    computed: {

    },
    watch:{

    },

    components:{


    }


});
